#include "stdafx.h"
#include "VFlowLayoutTest.h"

// Window /////////////////////////////////////////////////////////////////////

//
Window::Window()
{
	//setGeometry(QRect(100,100,400,400));
	setMaximumWidth(1000);
	setMinimumWidth(1000);
	setContentsMargins(0,0,0,0);

	QVBoxLayout *wbl = new QVBoxLayout;
		//wbl->setSizeConstraint(QLayout::SetMinimumSize);
		//wbl->setSizeConstraint(QLayout::SetMaximumSize);
		wbl->setContentsMargins(0,0,0,0);
		wbl->setAlignment(Qt::AlignTop);// | Qt::AlignHCenter);
		wbl->setSpacing(0);

	setLayout(wbl);


	for (int i = 0; i < 30; ++i) {
		QString sI = QString("_%1").arg(i);
	
		VFlowLayout *flowLayout = new VFlowLayout;
			if (i == 0)
				flowLayout->setAlignment(Qt::AlignHCenter);
			else if (i == 1)
				flowLayout->setAlignment(Qt::AlignRight);

		wbl->addLayout(flowLayout);

		//QPushButton *pb;
		VLineEdit *le;

		flowLayout->addWidget(le = new VLineEdit);
			le->setFontPointSize(10);
			le->setText(tr("AAAA") + sI);

		flowLayout->addWidget(le = new VLineEdit);
			le->setFontPointSize(20);
			le->setText(tr("BBBB") + sI);

		flowLayout->addWidget(le = new VLineEdit);
			le->setFontPointSize(14);
			le->setText(tr("CCCC") + sI);
			
/*
		if (i == 6) {
			VHBoxLayout *hbl;
			flowLayout->addLayout(hbl = new VHBoxLayout);
				hbl->addWidget(le = new VLineEdit);
					le->setText("Comment");
					
				hbl->addWidget(le = new VLineEdit);
					le->setFontPointSize(26);
					le->setText("Sergey");
		}
*/				
		//hbl->addWidget(new QPushButton(tr("Even longer button text")));

		if (i == 5) {
			//VTextEdit *te;
			//flowLayout->addWidget(te = new VTextEdit);
			//	te->setHtml("hbl->addWidget\r\n(new <b>QPushButton</b>(tr(Even longer button text)));");

			//VLabel *lb;
			//flowLayout->addWidget(lb = new VLabel);
			//	lb->setText("label");
		}
	}

	wbl->addWidget(new QPushButton(tr("end button")));
	//wbl->addWidget(new VLineEdit);

  setWindowTitle(tr("Flow Layout"));
  setPalette(QColor(255,255,255));
}

// VFlowLayoutTest ////////////////////////////////////////////////////////////

//
VFlowLayoutTest::VFlowLayoutTest(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);
}

//
VFlowLayoutTest::~VFlowLayoutTest()
{
}

/*************************************
QTextDocument * QTextEdit::document () const

QTextBlock QTextDocument::begin () const
QTextBlock QTextDocument::findBlockByLineNumber ( int lineNumber ) const
QTextBlock QTextDocument::firstBlock () const

int QTextBlock::lineCount () const
QTextCharFormat QTextBlock::charFormat () const

QFont QTextCharFormat::font () const


**************************************/